import service from "../index.js";
import qs from "qs";

const roomApi = {
    //添加房间
    insert(room){
        return service.post('/admin/room',room);
    },
    //根据id删除
    delete(id){
        return service.delete(`/admin/room/${id}`)
    },
    //根据ids删除
    deleteByIds(ids){

        return service.delete(`/admin/room/byIds`,  {
            params: { ids }, // 改为对象格式
            paramsSerializer: params =>
                qs.stringify(params, { arrayFormat: 'repeat' })
        })
    },
    //修改
    update(room){
        return service.put('/admin/room',room);
    },
    //根据ids删除
    updateByRooms(rooms){
        return service.post(`/admin/room/byRooms`,rooms)
    },
    //查询所有
    selectByPage(pageNum, pageSize, room){
        room.pageNum = pageNum;
        room.pageSize = pageSize;

        //请求参数
        return service.get('/admin/room', {params: room});
    },
    //根据id查询
    selectById(id){
        return service.get(`/admin/room/${id}`)
    },
}
export default roomApi;